@extends('app')
@section('content')
<ul class="nav nav-tabs">
    <li><a href="{{ url('/admin/enterprise/users')}}">信息列表</a></li>
    <li class="active"><a href="#">信息编辑</a></li>
</ul>
<form id="jobsForm" method="post">
    <div class="panel panel-default description2 mt20">
         <div class="form-group">
            <div class="col-sm-2 control-label">企业名称：</div>
            <div class="col-sm-6">
                <select name="company_id" class="form-control">
                    <option value="0">---请选择企业---</option>
                    @foreach($companys as $comp)
                    <option value="{{ $comp->id }}" @if(!empty($result)) @if($comp->id == $result->company_id) selected @endif @endif>{{ $comp->name }}</option>
                    @endforeach
                </select>                
            </div>
            <div class="clear"></div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户昵称</label>
            <div class="col-sm-9 col-xs-12">
                <input type="text" class="form-control" name="name" placeholder="昵称" value="@if(!empty($result)){{ $result->name }}@endif">
            </div>
        </div>
        @if(!empty($result))
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户头像</label>
            <div class="col-sm-9 col-xs-12">
                <input id="uploadimg" name="uploadimg" type="file" multiple="true">
                <div id="imgbox" class="dustbin">
                    <div>
                        <img src='@if(!empty($result)){{ $result->logo }}@endif' />
                    </div>
                </div>
            </div>
        </div>
        @endif
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">登陆邮箱:</label>
            <div class="col-sm-9 col-xs-12">
                <input type="email" class="form-control" name="email" placeholder="邮箱" value="@if(!empty($result)){{ $result->email }}@endif">
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号码:</label>
            <div class="col-sm-9 col-xs-12">
                  <input type="number" class="form-control" name="phone" id="phone" value="@if(!empty($result)){{$result->phone}}@endif" placeholder="手机号码">
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">登陆密码:</label>
            <div class="col-sm-9 col-xs-12">
                <div class="tagsinput-primary">
                    <input name="password" type="password" class="form-control" value="" />
                </div>
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">确认密码:</label>
            <div class="col-sm-9 col-xs-12">
                  <input type="password" class="form-control" name="repassword" id="repassword" >
            </div>
        </div>
       <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">QQ号码:</label>
            <div class="col-sm-9 col-xs-12">
                  <input type="number" name="qq" class="form-control"  value="@if(!empty($result)){{$result->qq}}@endif"> 
             </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">个性签名:</label>
            <div class="col-sm-9 col-xs-12">
              <input type="text" name="signature" class="form-control"  value="@if(!empty($result)){{$result->signature}} @endif"> 
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名:</label>
            <div class="col-sm-9 col-xs-12">
                  <input type="text" class="form-control" name="real_name" value="@if(!empty($result)) {{ $result->real_name}} @endif">
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户性别:</label>
            <div class="col-sm-9 col-xs-12">
                <label class="radio-inline">
                  <input type="radio" name="sex"  value="0" @if(!empty($result)) @if($result->sex == 0) checked @endif @else checked @endif> 女
                </label>
                <label class="radio-inline">
                  <input type="radio" name="sex" value="1" @if(!empty($result)) @if($result->sex == 1) checked @endif @endif> 男
                </label>
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否激活:</label>
            <div class="col-sm-9 col-xs-12">
                 <label class="radio-inline">
                  <input type="radio" name="is_active"  value="0" @if(!empty($result)) @if($result->is_active == 0) checked @endif @else checked @endif> 否
                </label>
                <label class="radio-inline">
                  <input type="radio" name="is_active" value="1" @if(!empty($result)) @if($result->is_active == 1) checked @endif @endif> 是
                </label>
            </div>
        </div>
        <div class="form-group clearfix">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户所属组:</label>
            <div class="col-sm-9 col-xs-12">
                @foreach($roles as $role)
                <label class="fl" style="margin-left:10px;"><input type="checkbox" name="role_id[]" value="{{$role->id}}" @if(!empty($result))@if(in_array($role->id,$result->userrole)) checked @endif @endif>{{$role->display_name}}</label>
                @endforeach
            </div>
        </div>
        {!! csrf_field() !!}
        <input type="hidden" name="userid" value="@if(!empty($result)){{ $result->id }}@endif">
        <input type="hidden" name="blademode" value="{{ $blademode }}">
        <div class="form-inline">
            <div class="form-group col-xs-offset-1">
              <button type="button" class="btn btn-info" onclick="saveData('/admin/enterprise/users','jobsForm')">
                    <i class="icon-ok bigger-110"></i>
                    Submit
              </button>
            </div>
            <div class="form-group col-xs-offset-1">
                <button type="reset" class="btn">
                    <i class="icon-undo bigger-110"></i>
                    Reset
                </button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
<!--
$('input').iCheck({
	checkboxClass: 'icheckbox_flat-blue',
    radioClass: 'iradio_flat-blue',
    increaseArea: '-10' // optional
});
	$(function(){
		/***图片上传****/
    	$("#uploadimg").uploadify({
    	    'formData'     : {
    	        'fileField':'upfile',
    	        '_token':'{{ csrf_token() }}'
    	    },
    	    "width"           : 120,
    	    "height"          : 30,
    	    "queueSizeLimit"  :1,
    	    "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
    	    "fileObjName"     : "upfile",
    	    "buttonText"      : "上传图片",
    	    "uploader"        : '/admin/upload/logo/{{!empty($result)?$result->id:0}}',
    	    'removeTimeout'	  : 1,
    	    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
    	    'onUploadSuccess':function(file, data, response){
    	    	var data = eval('(' + data + ')');
    	        if (data.status == 'success') {
    
    	            var html="<div><img src='"+data.attach+"' /></div>";
    	            $('#imgbox').html(html);
//     	            bindImg();
    	        }else{
    	            alert(data.msg);
    	            return false;
    	        }
    
    	    }
    
    	});
		
	});
//-->
</script>
@endsection
